<?PHP

class ItemBlackoutBO extends BusinessObject{
  /* private function using in constructors*/
  function setAttributes(){
    $this->fields   = array(
			"id"                =>	"items_blackout_id",
			"item_id"           =>	"items_blackout_itemid",
			"startdate"         =>	"items_blackout_startdate",
			"finishdate"        =>	"items_blackout_finishdate"
		);

    BusinessObject::setAttributes();
  }
  /* constuctor */
  function ItemBlackoutBO(){
    /** super(tableName) */
    BusinessObject::BusinessObject("items_blackout");
    $this->setAttributes();
  }
  
  //format of date  "2007-12-31"
  //return true if date in blackout period
	function isBlackout($item_id,$date_to_check) {
    	$sd = new ItemBlackoutBO();
		$sd->item_id = $item_id;
		$where = "(".$sd->fields["finishdate"]." >= DATE('".$date_to_check."') AND ".$sd->fields["startdate"]." <= DATE('".$date_to_check."'))";
		if ($sd->getCount($where) > 0)
			return true;
		else
			return false;
	}
} 
?>